package study.week03.gateway_final;

import study.week03.gateway_final.filter.CustomHttpFilter;
import study.week03.gateway_final.filter.CustomHttpFilter1;
import study.week03.gateway_final.filter.CustomRandomRefuseHttpFilter;
import study.week03.gateway_final.netty.NettyHttpServer;
import study.week03.gateway_final.router.CustomRouter;
import study.week03.gateway_final.router.RandomCustomRouter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class GatewayFinalDemoApplication {
    public static void main(String[] args) throws InterruptedException {
        //本服务的端口和业务服务器的url
        int port = 10097;
        //服务器列表
        List<String> serverList = Arrays.asList("http://127.0.0.1:8801","http://127.0.0.1:8802");
        //过滤器链
        // 一个过滤器增加请求头和响应头
        // 一个过滤器随机拒绝部分请求触发拒绝策略
        CustomHttpFilter[] filterChain = {new CustomHttpFilter1(),new CustomRandomRefuseHttpFilter()};
        //路由
        CustomRouter router = new RandomCustomRouter();
        //启动
        new NettyHttpServer().start(port,filterChain,serverList,router);
    }

}
